﻿@using OBUCare.Core.Models
@using OBUCare.Web.Models
@using OBUCare.Web.Infrastructure
 
<link href="../../Content/tableCss.css" rel="stylesheet" type="text/css" />
<table width="100%">
    <tr>
        <td align="center">
            <span class="pTitle">厂商维修周期明细</span>
        </td>
    </tr>
    <tr>
        <td>
            &nbsp;
        </td>
    </tr>
    <tr>
        <td align="center">
            @Html.Partial("_RepairDetailSearch")
        </td>
    </tr>
    <tr>
        <td align="center">
            @(Html.Telerik().Grid<RepairTimeDetailModel>()
        .Name("Grid")
        .Sortable(sorting => sorting.SortMode(GridSortMode.SingleColumn))
        .DataBinding(dataBinding => dataBinding
            .Ajax()
                  .Select("ListRepairTimeDetail", "Report")
                    )
        .Columns(columns =>
        {
            columns.Bound(o => o.AGENT_NAME).Width(100);
            columns.Bound(o => o.OBU_NO).Width(140);
            columns.Bound(o => o.SHORTNAME).Width(100);
            columns.Bound(o => o.CURRENT_STATUS).Width(150);
            columns.Bound(o => o.CREATED_DATE).Format("{0:yyyy-MM-dd}").Width(130);
            columns.Bound(o => o.REPAIR_DAYS).Width(100);
        }).TableHtmlAttributes(new { @style = "width:900px" })
        .ClientEvents(events =>
        {
            events.OnError("onError");
            events.OnDataBinding("onDataBinding");
        })
        .Pageable(paging =>
        {
            paging.Style(CommonStyleForUI.Grid_PageStyle)
            .Position(CommonStyleForUI.Grid_PagePosition)
            .PageTo(CommonStyleForUI.Grid_CurrentPage)
            .PageSize(CommonStyleForUI.Grid_PageSize, new int[] { 10, 20, 50, 100, 200, 500 });
        })
                    //.Resizable(resizing => resizing.Columns(true))
        .Scrollable(scroll => scroll.Height(CommonStyleForUI.Grid_Height))
                    //.Selectable()
)
        </td>
    </tr>
</table>
<script type="text/javascript">
    function onError(e) {
        //debugger;
        e.preventDefault();
        /*if (e.XMLHttpRequest.status == "505")
        alert("系统字段不允许删除");
        else if (e.XMLHttpRequest.status == "506")
        alert("系统表不允许删除");
        else*/
        alert(e.XMLHttpRequest.getResponseHeader("message"));
    }

    var index = 0;

    function onDataBinding(e) {
        var strSearchSql = $('#sql').val();
        var strCheckDay = $('#Check_Day').val();
        //grid自带的查询事件时，将其取消，只保留手动执行的查询
        if (strSearchSql.StringIsNullOrEmpty() || strCheckDay.StringIsNullOrEmpty() )
            e.preventDefault();

        var grid = $('#Grid').data('tGrid')
        index = (grid.currentPage - 1) * grid.pageSize;
        e.data = {
            // the key ("category") specifies the variable name of the action method which will contain the specified value
            searchSql: $('#searchSql').val(),
            sql: $('#sql').val(),
            Check_Day: $('#Check_Day').val()
        };
    }
</script>
